﻿

using System.Collections.Generic;
using System.Text;
using UtilLib;

public static partial class Efun
{
    public static readonly string BusyMessage = "你正忙着呢";
    public static string DescLevel(int value)
    {
        var lv = Clamp(value, ConfDescLevel.Keys.Min(), ConfDescLevel.Keys.Max());
        return ConfDescLevel[lv].ColorName();
    }
    public static string DescDamage(int value)
    {
        var lv = Clamp(value / 25, ConfDescDamage.Keys.Min(), ConfDescDamage.Keys.Max());
        return ConfDescDamage[lv].Desc;
    }

    public static string DescKee(int value, int max)
    {
        var pct = 0;
        if (max > 0)
        {
            pct = value * 100 / max;
        }
        pct = Clamp(pct, 0, 100);
        foreach (var item in ConfCbtKee.Values)
        {
            if (pct >= item.Vmin && pct < item.Vmax)
            {
                return item.Desc;
            }
        }
        return ConfCbtKee.Values.First().Desc;
    }
    public static string DescEffKee(int value, int max)
    {
        var pct = 0;
        if (max > 0)
        {
            pct = value * 100 / max;
        }
        pct = Clamp(pct, 0, 100);
        foreach (var item in ConfCbtEffKee.Values)
        {
            if (pct >= item.Vmin && pct < item.Vmax)
            {
                return item.Desc;
            }
        }
        return ConfCbtEffKee.Values.First().Desc;
    }
    public static string DescSen(int value, int max)
    {
        var pct = 0;
        if (max > 0)
        {
            pct = value * 100 / max;
        }
        pct = Clamp(pct, 0, 100);
        foreach (var item in ConfCbtSen.Values)
        {
            if (pct >= item.Vmin && pct < item.Vmax)
            {
                return item.Desc;
            }
        }
        return ConfCbtSen.Values.First().Desc;
    }
    public static string DescPer(int age, EGender gender, int per)
    {
        if (age < 14)
        {
            var perlv = Clamp((per - 10) / 5, ConfDescPer1.Keys.Min(), ConfDescPer1.Keys.Max());
            return ConfDescPer1[perlv].Desc.RandomSingle();
        }
        else
        {
            if (gender == EGender.女性)
            {
                var perlv = Clamp(per, ConfDescPer3.Keys.Min(), ConfDescPer3.Keys.Max());
                return ConfDescPer3[perlv].Desc;
            }
            else
            {
                var perlv = Clamp(per, ConfDescPer2.Keys.Min(), ConfDescPer2.Keys.Max());
                return ConfDescPer2[perlv].Desc;
            }
        }
    }
}
